
using System.Security.Claims;
namespace QDCommon.Controller
{
    public class UserIdentityHelper
    {
        public static string GetUserName(ClaimsPrincipal info)
        {
            return info.Identity.Name;
        }

        public static long? GetUserId(ClaimsPrincipal info)
        {
            if (info != null)
            {
                foreach (Claim claim in info.Claims)
                {
                    if (claim.Type == ClaimTypes.Sid)
                    {
                        return long.Parse(claim.Value);
                    }
                }
            }
            return null;
        }
        public static long? GetUserLoginTime(ClaimsPrincipal info)
        {
            if (info != null)
            {
                foreach (Claim claim in info.Claims)
                {
                    if (claim.Type == "UserLoginTime")
                    {
                        return long.Parse(claim.Value);
                    }
                }
            }
            return null;
        }
    }
}